package com.aaa.marketing.service.impl;/**
 * Date:2023/3/2
 * Author：臣哥哥
 * Description:
 */

import com.aaa.entity.Company;
import com.aaa.marketing.dao.CompanyDao;
import com.aaa.marketing.service.CompanyService;
import com.aaa.vo.Result;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author     ：Xiaochen
 * @date       ：Created in 2023/3/2 11:53
 * @description：
 * @modified By：
 * @version:
 */
@Service
public class CompanyServiceImpl implements CompanyService {
    @Autowired
    private CompanyDao companyDao;
    @Override
    public Result selectAll(int currentPage, int pageSize, Company company) {
        PageHelper.startPage(currentPage,pageSize);
        List<Company> companies = companyDao.selectAll(company);
        PageInfo<Company> companyPageInfo = new PageInfo<>(companies);
        return new Result(2000,"成功",companyPageInfo);
    }

    @Override
    public Result update(Company company) {
        int i = companyDao.updateById(company);
        return new Result(2000,"成功",i);
    }

    @Override
    public Result delete(Integer id) {
        int i = companyDao.deleteById(id);
        return new Result(2000,"成功",i);
    }

    @Override
    public Result insert(Company company) {
        int insert = companyDao.insert(company);
        return new Result(2000,"成功",insert);
    }
}